package com.liwy3.job.config;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Copyright © 元气森林（北京）食品科技集团有限公司. All rights reserved.
 *
 * @Description:
 * @author: Crazy4J
 * @date: 2021年12月22日 20:12
 * @version: V1.0
 */
@Component
@Slf4j
public class MyDemoJob {
    @Resource
    private Environment environment;

    @XxlJob("demoJob1")
    public void demoJob1()  {
        int shardIndex = XxlJobHelper.getShardIndex();
        int shardTotal = XxlJobHelper.getShardTotal();
//        try {
//            int i = 1/0;
//        }catch (Exception e){
//            log.error("demoJob1异常了",e);
//        }

        System.out.println(environment.getProperty("server.port") +"测试1");
    }

}
